﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Configuration;

namespace ManagementProject
{
    public partial class TestForm : Form
    {
        public TestForm()
        {
            InitializeComponent();
            LoadCategory();
        }

        void LoadCategory()
        {
            SqlConnection con = new SqlConnection();
            con.ConnectionString = ConfigurationManager.ConnectionStrings["conStr"].ConnectionString;

            SqlDataAdapter da = new SqlDataAdapter("SELECT CategoryID, CategoryName FROM Production.Categories", con);
            DataTable dt = new DataTable("Categories");
            da.Fill(dt);

            cmbCategory.DataSource=dt;
            cmbCategory.DisplayMember = "CategoryName";
            cmbCategory.ValueMember = "CategoryID";
        }

        private void btnShow_Click(object sender, EventArgs e)
        {
            int CategoryID = (int)cmbCategory.SelectedValue;
            MessageBox.Show(CategoryID.ToString());
        }
    }
}
